//
//  String+Category.swift
//  SwiftWeiBo
//
//  Created by wyw on 16/10/9.
//  Copyright © 2016年 Style_Y. All rights reserved.
//

import Foundation

extension String
{
    /**
     *  返回缓存路径的完整路径名
     */
    func cacheDir() -> String {
        let cir = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.cachesDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).last! as NSString
        
        return cir.appendingPathComponent((self as NSString).lastPathComponent)
    }
    
    /**
     *  返回文档路径的完整路径名
     */
    func documentDir() -> String {
        let dir = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).last! as NSString
        return dir.appendingPathComponent((self as NSString).lastPathComponent)
    }
    
    /**
     *  返回临时路径的完整路径名
     */
    func tempDir() -> String {
        let tir = NSTemporaryDirectory() as NSString
        return tir.appendingPathComponent((self as NSString).lastPathComponent)
    }
    
}
